﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace dbe.FoundationLibrary.Core.Win32.API
{
    /// <summary>
    /// Win32Api函数需要的常量，原型为MFC中的wingdi.h
    /// </summary>
    public struct WinGdi
    {
        public const int OUT_DEFAULT_PRECIS = 0;
        public const int OUT_STRING_PRECIS = 1;
        public const int OUT_CHARACTER_PRECIS = 2;
        public const int OUT_STROKE_PRECIS = 3;
        public const int OUT_TT_PRECIS = 4;
        public const int OUT_DEVICE_PRECIS = 5;
        public const int OUT_RASTER_PRECIS = 6;
        public const int OUT_TT_ONLY_PRECIS = 7;
        public const int OUT_OUTLINE_PRECIS = 8;
        public const int OUT_SCREEN_OUTLINE_PRECIS = 9;
        public const int OUT_PS_ONLY_PRECIS = 10;

        
        public const int CLIP_DEFAULT_PRECIS = 0;
        public const int CLIP_CHARACTER_PRECIS = 1;
        public const int CLIP_STROKE_PRECIS = 2;
        public const int CLIP_MASK = 0xf;
        public const int CLIP_LH_ANGLES = (1 << 4);
        public const int CLIP_TT_ALWAYS = (2 << 4);
        public const int CLIP_EMBEDDED = (8 << 4);

        public const int DEFAULT_QUALITY = 0;
        public const int DEFAULT_PITCH = 0;

        /* Character Sets */
        public const int ANSI_CHARSET = 0;
        public const int DEFAULT_CHARSET = 1;
        public const int SYMBOL_CHARSET = 2;
        public const int GB2312_CHARSET = 134;
        public const int CHINESEBIG5_CHARSET = 136;
        public const int OEM_CHARSET = 255;
        // ...

        /* Font Families */
        public const int FF_DONTCARE = (0 << 4);  /* Don't care or don't know. */
        public const int FF_ROMAN = (1 << 4);  /* Variable stroke width, serifed. */
        public const int FF_SWISS = (2 << 4);  /* Variable stroke width, sans-serifed. */
        public const int FF_MODERN = (3 << 4);  /* Constant stroke width, serifed or sans-serifed. */
        public const int FF_SCRIPT = (4 << 4);  /* Cursive, etc. */
        public const int FF_DECORATIVE = (5 << 4);  /* Old English, etc. */


        /* Font Weights */
        public const int FW_DONTCARE = 0;
        public const int FW_THIN = 100;
        public const int FW_EXTRALIGHT = 200;
        public const int FW_LIGHT = 300;
        public const int FW_NORMAL = 400;
        public const int FW_MEDIUM = 500;
        public const int FW_SEMIBOLD = 600;
        public const int FW_BOLD = 700;
        public const int FW_EXTRABOLD = 800;
        public const int FW_HEAVY = 900;

        public const int FW_ULTRALIGHT = FW_EXTRALIGHT;
        public const int FW_REGULAR = FW_NORMAL;
        public const int FW_DEMIBOLD = FW_SEMIBOLD;
        public const int FW_ULTRABOLD = FW_EXTRABOLD;
        public const int FW_BLACK = FW_HEAVY;


        /* Pen Styles */
        public const int PS_SOLID = 0;
        public const int PS_DASH = 1;               /* -------  */
        public const int PS_DOT = 2;                /* .......  */
        public const int PS_DASHDOT = 3;            /* _._._._  */
        public const int PS_DASHDOTDOT = 4;         /* _.._.._  */
        public const int PS_NULL = 5;
        public const int PS_INSIDEFRAME = 6;
        public const int PS_USERSTYLE = 7;
        public const int PS_ALTERNATE = 8;
        public const int PS_STYLE_MASK = 0x0000000F;

        public const uint PS_ENDCAP_ROUND = 0x00000000;
        public const uint PS_ENDCAP_SQUARE = 0x00000100;
        public const uint PS_ENDCAP_FLAT = 0x00000200;
        public const uint PS_ENDCAP_MASK = 0x00000F00;

        public const uint PS_JOIN_ROUND = 0x00000000;
        public const uint PS_JOIN_BEVEL = 0x00001000;
        public const uint PS_JOIN_MITER = 0x00002000;
        public const uint PS_JOIN_MASK = 0x0000F000;

        public const uint PS_COSMETIC = 0x00000000;
        public const uint PS_GEOMETRIC = 0x00010000;
        public const uint PS_TYPE_MASK = 0x000F0000;

        /// <summary>
        /// currentlly defined blend function
        /// </summary>
        public const int AC_SRC_OVER = 0x00;
        /// <summary>
        /// alpha format flags
        /// </summary>
        public const int AC_SRC_ALPHA = 0x01;
    }

    /// <summary>
    /// 修改电脑屏幕分辨率相关，用于存储设备模式信息的结构体
    /// </summary>
    /// <remarks>
    /// 设备模式是指图形应用程序与设备（如显示器、打印机等）进行交互时使用的设置和属性。
    /// </remarks>
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
    public struct _devicemode
    {
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
        public string dmDeviceName;

        public short dmSpecVersion;
        public short dmDriverVersion;
        public short dmSize;
        public short dmDriverExtra;
        public int dmFields;
        public int dmPositionX;
        public int dmPositionY;
        public int dmDisplayOrientation;
        public int dmDisplayFixedOutput;
        public short dmColor;
        public short dmDuplex;
        public short dmYResolution;
        public short dmTTOption;
        public short dmCollate;

        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
        public string dmFormName;

        public short dmLogPixels;
        public short dmBitsPerPel;
        public int dmPelsWidth;
        public int dmPelsHeight;
        public int dmDisplayFlags;
        public int dmDisplayFrequency;
        public int dmICMMethod;
        public int dmICMIntent;
        public int dmMediaType;
        public int dmDitherType;
        public int dmReserved1;
        public int dmReserved2;
        public int dmPanningWidth;
        public int dmPanningHeight;
    }

    /// <summary>
    /// 定义tagPOINT结构
    /// </summary>
    /// <remarks>
    /// 原型来自wingdi.h中的同名结构体。对应的结构体/结构体指针包括POINT, *PPOINT, NEAR *NPPOINT, FAR *LPPOINT
    /// </remarks>
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
    public struct tagPOINT
    {
        public int x;
        public int y;
    }

    /// <summary>
    /// 定义TRIVERTEX结构
    /// </summary>
    /// <remarks>
    /// 原型来自wingdi.h中的同名结构体。怀疑可以直接使用tagPOINT即可。证实后可删除本结构体。
    /// </remarks>
    [StructLayout(LayoutKind.Sequential)]
    public struct POINT
    {
        public int X;
        public int Y;

        public POINT(int x, int y)
        {
            X = x;
            Y = y;
        }
    }

    /// <summary>
    /// 定义_TRIVERTEX结构
    /// </summary>
    /// <remarks>
    /// 原型来自wingdi.h中的同名结构体。对应的结构体/结构体指针包括TRIVERTEX,*PTRIVERTEX,*LPTRIVERTEX
    /// </remarks>
    [StructLayout(LayoutKind.Sequential)]
    public struct _TRIVERTEX
    {
        public int X;
        public int Y;
        public uint Red;
        public uint Green;
        public uint Blue;
        public uint Alpha;
    }

    /// <summary>
    /// 定义_GRADIENT_RECT结构
    /// </summary>
    /// <remarks>
    /// 原型来自wingdi.h中的同名结构体。对应的结构体/结构体指针包括GRADIENT_RECT,*PGRADIENT_RECT,*LPGRADIENT_RECT
    /// </remarks>
    [StructLayout(LayoutKind.Sequential)]
    public struct _GRADIENT_RECT
    {
        public int UpperLeft;
        public int LowerRight;
    }

    /// <summary>
    /// 定义_BLENDFUNCTION结构
    /// </summary>
    /// <remarks>
    /// 原型来自wingdi.h中的同名结构体。对应的结构体/结构体指针包括BLENDFUNCTION,*PBLENDFUNCTION
    /// </remarks>
    public struct _BLENDFUNCTION
    {
        public byte BlendOp;
        public byte BlendFlags;
        public byte SourceConstantAlpha;
        public byte AlphaFormat;
    }
}